package org.jsola.hr.query;

import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import org.jsola.core.query.BaseQuery;
import org.jsola.orm.filter.Order;
import org.springframework.util.CollectionUtils;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

import static org.jsola.hr.example.SocDispatchEmpAddExample.E_ALL_AMOUNT;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_ASSIGN_COMPANY_ID;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_ASSIGN_COMPANY_NAME;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_COMPANY_AMOUNT;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_COMPANY_ID;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_COMPANY_PF_AMOUNT;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_COMPANY_SOC_AMOUNT;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_FUND_START_DATE_END;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_FUND_START_DATE_START;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_HAS_RECEIVE;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_HAS_SEND;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_ID_CARD;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_IS_SHIFT;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_MONTH;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_NAME;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_NO_ERROR;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_PERSONAL_AMOUNT;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_PERSONAL_PF_AMOUNT;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_PERSONAL_SOC_AMOUNT;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_PHONE;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_REMAKE;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_SOC_CITY_ID;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_SOC_CITY_NAME;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_SOC_DISPATCH_ID;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_SOC_PROG_ID;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_SOC_PROG_NAME;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_SOC_START_DATE_END;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_SOC_START_DATE_START;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_SORT;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_STATUS;
import static org.jsola.hr.example.SocDispatchEmpAddExample.E_YEAR;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_ALL_AMOUNT;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_ASSIGN_COMPANY_ID;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_ASSIGN_COMPANY_NAME;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_COMPANY_AMOUNT;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_COMPANY_ID;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_COMPANY_PF_AMOUNT;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_COMPANY_SOC_AMOUNT;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_FUND_START_DATE_END;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_FUND_START_DATE_START;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_HAS_RECEIVE;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_HAS_SEND;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_ID_CARD;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_IS_SHIFT;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_MONTH;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_NAME;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_NO_ERROR;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_PERSONAL_AMOUNT;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_PERSONAL_PF_AMOUNT;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_PERSONAL_SOC_AMOUNT;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_PHONE;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_REMAKE;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_SOC_CITY_ID;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_SOC_CITY_NAME;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_SOC_DISPATCH_ID;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_SOC_PROG_ID;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_SOC_PROG_NAME;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_SOC_START_DATE_END;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_SOC_START_DATE_START;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_SORT;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_STATUS;
import static org.jsola.hr.example.SocDispatchEmpAddExample.N_YEAR;

/**
 * 社保派单员工表_增员
 *
 * @author zhr
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class SocDispatchEmpAddQuery extends BaseQuery {

    private static final long serialVersionUID = 1L;

    @ApiParam(value = N_SOC_DISPATCH_ID, example = E_SOC_DISPATCH_ID)
    @Length(max = 32)
    private String socDispatchId;

    @ApiParam(value = N_YEAR, example = E_YEAR)
    @Length(max = 12)
    private String year;

    @ApiParam(value = N_MONTH, example = E_MONTH)
    @Length(max = 10)
    private String month;

    @ApiParam(value = N_NAME, example = E_NAME)
    @Length(max = 50)
    private String name;

    @ApiParam(value = N_PHONE, example = E_PHONE)
    @Length(max = 20)
    private String phone;

    @ApiParam(value = N_ID_CARD, example = E_ID_CARD)
    @Length(max = 32)
    private String idCard;

    @ApiParam(value = N_SOC_PROG_NAME, example = E_SOC_PROG_NAME)
    @Length(max = 100)
    private String socProgName;

    @ApiParam(value = N_SOC_PROG_ID, example = E_SOC_PROG_ID)
    @Length(max = 32)
    private String socProgId;

    @ApiParam(value = N_SOC_CITY_NAME, example = E_SOC_CITY_NAME)
    @Length(max = 100)
    private String socCityName;

    @ApiParam(value = N_SOC_CITY_ID, example = E_SOC_CITY_ID)
    private Long socCityId;

    /**
     * 社保起缴时间查询范围
     */
    @ApiParam(value = N_SOC_START_DATE_START, example = E_SOC_START_DATE_START)
    private Date socStartDateStart;
    @ApiParam(value = N_SOC_START_DATE_END, example = E_SOC_START_DATE_END)
    private Date socStartDateEnd;


    /**
     * 公积金起缴时间查询范围
     */
    @ApiParam(value = N_FUND_START_DATE_START, example = E_FUND_START_DATE_START)
    private Date fundStartDateStart;
    @ApiParam(value = N_FUND_START_DATE_END, example = E_FUND_START_DATE_END)
    private Date fundStartDateEnd;


    @ApiParam(value = N_IS_SHIFT, example = E_IS_SHIFT)
    private Boolean isShift;

    @ApiParam(value = N_ASSIGN_COMPANY_ID, example = E_ASSIGN_COMPANY_ID)
    @Length(max = 32)
    private String assignCompanyId;

    @ApiParam(value = N_ASSIGN_COMPANY_NAME, example = E_ASSIGN_COMPANY_NAME)
    @Length(max = 100)
    private String assignCompanyName;

    @ApiParam(value = N_REMAKE, example = E_REMAKE)
    @Length(max = 2147483647)
    private String remake;

    @ApiParam(value = N_HAS_SEND, example = E_HAS_SEND)
    private Boolean hasSend;

    @ApiParam(value = N_HAS_RECEIVE, example = E_HAS_RECEIVE)
    private Boolean hasReceive;

    @ApiParam(value = N_STATUS, example = E_STATUS)
    private Integer status;

    @ApiParam(value = N_PERSONAL_SOC_AMOUNT, example = E_PERSONAL_SOC_AMOUNT)
    private BigDecimal personalSocAmount;

    @ApiParam(value = N_PERSONAL_PF_AMOUNT, example = E_PERSONAL_PF_AMOUNT)
    private BigDecimal personalPfAmount;

    @ApiParam(value = N_PERSONAL_AMOUNT, example = E_PERSONAL_AMOUNT)
    private BigDecimal personalAmount;

    @ApiParam(value = N_COMPANY_SOC_AMOUNT, example = E_COMPANY_SOC_AMOUNT)
    private BigDecimal companySocAmount;

    @ApiParam(value = N_COMPANY_PF_AMOUNT, example = E_COMPANY_PF_AMOUNT)
    private BigDecimal companyPfAmount;

    @ApiParam(value = N_COMPANY_AMOUNT, example = E_COMPANY_AMOUNT)
    private BigDecimal companyAmount;

    @ApiParam(value = N_ALL_AMOUNT, example = E_ALL_AMOUNT)
    private BigDecimal allAmount;

    @ApiParam(value = N_NO_ERROR, example = E_NO_ERROR)
    private Boolean noError;

    @ApiParam(value = N_COMPANY_ID, example = E_COMPANY_ID)
    @Length(max = 32)
    private String companyId;

    @ApiParam(value = N_SORT, example = E_SORT)
    private Integer sort;



    @ApiParam(value = "排序字段", allowMultiple=true, type="Order" ,example = "\"orders\": [{\"property\": \"userName\",\"desc\": false}]")
    private List<Order> orders;

    /**
     * 每页的条数
     */
    @ApiParam(value = "分页参数，每页的条数", example = "20")
    @Max(value = 1000, message = "pageSize不能大于1000")
    private Integer pageSize = 20;

    /**
     * 当前第几页
     */
    @ApiParam(value = "分页参数，第几页", example = "1")
    @Min(value = 1, message = "pageNo不能小于1")
    private Integer pageNo = 1;

    @ApiParam(value = "是否展示导入员工的分项信息,默认不展示")
    private Boolean showItem = false;

    /**
     * 添加排序
     * @param propertyName 属性名
     * @param desc 是否降序
     * @return this
     */
    public SocDispatchEmpAddQuery addOrder(String propertyName, boolean desc) {
        if (CollectionUtils.isEmpty(this.orders)) {
            this.orders = new ArrayList<>();
        }
        this.orders.add(new Order(propertyName,desc));
        return this;
    }

}

